package com.flyxiaozhu.erp.core.entities;

import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;

@Entity
@Data
@DynamicInsert
@DynamicUpdate
public class SysLog extends BaseEntity {
    @Column(columnDefinition = "varchar(64) NOT NULL DEFAULT '' COMMENT '用户名'")
    private String username;

    @Column(columnDefinition = "tinyint(2) NOT NULL DEFAULT 0 COMMENT '方法类型，0-新增、1-修改、2-删除'")
    private int methodType;

    @Column(columnDefinition = "varchar(64) NOT NULL DEFAULT '' COMMENT '实体'")
    private String entity;

    @Column(columnDefinition = "int(11) NOT NULL DEFAULT 0 COMMENT '数据ID'")
    private Long dataId;

    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(columnDefinition = "text comment '方法描述'", nullable = false)
    private String methodDescription;

    @Column(columnDefinition = "varchar(6) NOT NULL DEFAULT '' COMMENT '请求方式'")
    private String requestMethod;

    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(columnDefinition = "text comment '请求参数'", nullable = false)
    private String requestParams;

    @Column(columnDefinition = "varchar(200) NOT NULL DEFAULT '' COMMENT '请求地址'")
    private String requestUrl;

    @Column(columnDefinition = "varchar(64) NOT NULL DEFAULT '' COMMENT '请求者ip地址'")
    private String requestIp;

    @Column(columnDefinition = "varchar(6) NOT NULL DEFAULT '' COMMENT '状态码'")
    private String requestCode;

    @Column(columnDefinition = "varchar(250) NOT NULL DEFAULT '' COMMENT '异常描述'")
    private String exceptionDetail;
}
